import { create } from 'zustand'
import type { Graph } from '@antv/x6'
import type { RefObject } from 'react'

interface ProcessMiningEngineState {
  graph: Graph | null
  containerRef: RefObject<HTMLDivElement | null> | null
  setGraph: (graph: Graph | null) => void
  setContainerRef: (ref: RefObject<HTMLDivElement | null>) => void
  leftSidebarVisible: boolean
  setLeftSidebarVisible: (visible: boolean) => void
  rightSidebarVisible: boolean
  setRightSidebarVisible: (visible: boolean) => void
  selectedProcess: Record<string, any> | null
  setSelectedProcess: (process: Record<string, any> | null) => void
  selectedNode: Record<string, any> | null
  setSelectedNode: (node: Record<string, any> | null) => void
  processConfig: Record<string, any> | null
  setProcessConfig: (config: Record<string, any> | null) => void

  filterConfig: Record<string, any> | null
  setFilterConfig: (config: Record<string, any> | null) => void
}

export const useProcessMiningEngineStore = create<ProcessMiningEngineState>((set) => ({
  graph: null,
  containerRef: null,
  setGraph: (graph) => set({ graph }),
  setContainerRef: (containerRef) => set({ containerRef }),
  leftSidebarVisible: true,
  setLeftSidebarVisible: (visible) => set({ leftSidebarVisible: visible }),
  rightSidebarVisible: true,
  setRightSidebarVisible: (visible) => set({ rightSidebarVisible: visible }),
  selectedProcess: null,
  setSelectedProcess: (process) => set({ selectedProcess: process }),
  selectedNode: null,
  setSelectedNode: (node) => set({ selectedNode: node }),
  processConfig: {
    showAllCase: true,
    showNodeWithData: true,
  },
  setProcessConfig: (config) => set({ processConfig: config }),
  filterConfig: {
    processDetails: 100,
  },
  setFilterConfig: (config) => set({ filterConfig: config }),
}))

